import { getInsuranceRecordList } from '@/api/insurance/record'
import type { InsuranceRecordDto } from '@/api/insurance/record/types'
import { getKeyToEnum, OperationTypeCnEnum } from '@/const/enum'
import type { FilterDto } from '@/render/FilterRender'
import TableRender, { type TableRenderColumnTypes } from '@/render/TableRender'
import toNative from '@/utils/toNative'
import { Component } from 'vue-facing-decorator'

@Component
export class CompanyBlack extends TableRender {
    filterConfig() {
        return {
            sourceName: {
                name: '数据来源',
                element: 'input'
            },
            // product: {
            //     name: '保险产品',
            //     element: 'input'
            // },
            operationType: {
                name: '操作属性',
                element: 'select',
                options: getKeyToEnum(OperationTypeCnEnum)
            }
        } as FilterDto
    }
    tableColumnConfig() {
        return [
            {
                field: 'operationType',
                title: '操作属性',
                params: {
                    enum: OperationTypeCnEnum
                },
                slots: {
                    default: 'enum'
                }
            },
            {
                field: 'total',
                title: '数量',
            },
            {
                field: 'sourceType',
                title: '数据来源',
            },
            {
                field: 'isSuccess',
                title: '状态',
                formatter({row}) {
                    return row.isSuccess ? '成功' : '失败'
                },
            },
            {
                field: 'companyPlanName',
                title: '方案简称',
            },
            // {
            //     field: 'createTime',
            //     title: '保险产品',
            // },
            {
                field: 'companyName',
                title: '客户名称',
                params: {
                    path:(row) => {
                        return `/customer/${row.companyId}`
                    },
                },
                slots: {
                    default: 'toNext'
                }
            },
            {
                field: 'managerName',
                title: '操作人',
            },
            {
                field: 'updateTime',
                title: '操作时间',
            },
        ] as TableRenderColumnTypes<InsuranceRecordDto>
    }
    
    onLoadData(page: number, size: number, filters: Parameters<typeof getInsuranceRecordList>[0]) {
        return getInsuranceRecordList({
            ...filters,
            pageNum: page,
            pageSize: size,
        })
    }
}

export default toNative(CompanyBlack)